home *** CD-ROM | disk | FTP | other *** search
-
- This package contains:
-
- A new component decended from TImage called TSImage, The 'S' is for
- auto-sizing.
-
- It was designed for my needs in a recent app. Thus it is fairly
- specific to what I needed to do: display 256 color bitmaps which
- are stored in files.
-
- Instead of using TImage.Picture.loadfromfile('') you use
-
- TSImage.ChangeFromFile(
- const FileName : string;
- Crop : Trect;
- Show_Cropped : boolean;
- Actual_Size : boolean);
-
- TSimage will automatically (and CLEANLY) remove any currently displayed
- image and displayed the new image, scaled bigger or SMALLER to fit in
- the designed size of the TSimage.
-
- The above words 'CLEANLY' and 'SMALLER' are two things TImage doesn't
- do out-of-the-box. To do it cleanly you need to learn a trick and to
- display it smaller you need to work around a bug (Stretch property
- doesn't work when squeezing).
- The auto-sizing is activated by the 'Actual_Size : boolean' parameter.
- Any property settings for 'AutoSize, Stretch, or Center' are ignored.
-
- You can also provide a crop rectangle that is the area of interest
- in the bitmap. It is then this area that is auto-sized to the designed
- size of the TSImage. The auto-sizing maintains the aspect ratio of the
- bitmap. This is an enhancement above what TImage can do.
- The cropping is activated by the 'Show_Cropped : boolean' parameter.
-
- A built-in 'crop tool' allows the user at runtime to frame the
- rectangle of interest in the bitmap.
-
- procedure croptool_on;
-
- procedure croptool_off(
- var changed : boolean;
- var Crop : Trect);
-
- The above 2 methods activate the crop tool and return the chosen Trect.
- The demo app BMPView shows how to use these methods, a real app would
- probabily save any user selected crop rect in a database, associated
- with the filename of the BMP file.
-
- The following method is used when you want to move the image in one
- TSimage into another. The demo program BMPVIEW uses this to implement
- the zoom to full screen capability.
-
- procedure ReplaceWith(
- fromImage : TSimage;
- Crop : Trect;
- Show_Cropped : boolean;
- Actual_Size : boolean);
-
- The following method is used when you want to redraw the image in a
- TSimage to change the crop rect or display mode booleans.
-
- procedure ReDraw(
- Crop : Trect;
- Show_Cropped : boolean;
- Actual_Size : boolean);
-
- See the demo app BMPView.exe and the source for further details.
- In the demo app, make sure you click on the image to see it zoom
- to full screen, and resize the form to see how the image window
- resizes. Plus load a bitmap that is larger than the window and
- select 'actual size' to see the use of scroll bars.
-
- Borland's Graphics.pas unit makes some assumptions dealing with
- BMP files that have proved incorrect. If you have BMP files
- that display correctly in other apps, by you get a
- Out-Of-System-Resources when you display them in Delphi, you
- could be running into this problem. Below is a source code
- change you can make to graphics.pas to solve this class of
- problems. The BMPview.exe demo program has been compiled with
- this patch in place.
-
- comment out lines 2099 and 2100 in graphics.pas:
-
- Dec(ImageSize, SizeOf(TBitmapInfoHeader) + Size);
- (* {never trust biSizeImage - prp01}
- if biSizeImage <> 0 then
- if biSizeImage < ImageSize then ImageSize := biSizeImage;
- *)
- BitsMem := MemAlloc(ImageSize);
-
-
- Released to the public 1-Jun-95 by Paul Peterson.
- Please report any problem (or enhancements you make) to 72371,1136
- via CIS Mail.
-
- Thank You.
- Later,
- Paul
-